#include<stdio.h>
#include<unistd.h>
#include<pthread.h>
//线程的入口函数
void* pthread_start(void* arg){
//    int* index = (int*)arg;
    while(1){
//        printf("i am work thread! %d\n", *index);
        sleep(1);
    }
//    delete index;
}
int main(){
    //创建一个线程
    for(int i = 0; i < 5; i++){
        pthread_t thread;
       // int* p = new int;
       // *p = i;
        int ret = pthread_create(&thread, NULL, pthread_start, NULL);
        if(ret < 0){
            perror("pthread_create");
            return 0;
        }
     //   sleep(1);
    }
    //主线程不退出，观察信息
    while(1){
        printf("i am main thread\n");
        sleep(1);
    }
    return 0;
}
